import logging
import json

from pylons import request, response, session, tmpl_context as c, url
from pylons.controllers.util import abort, redirect

from sqlalchemy import desc, func
from sqlalchemy.exc import IntegrityError

from fidoweb.lib.base import Session, BaseController, render
from fidoweb.model.map import *
from fidoweb.lib.algorithm import checkTimeScope

log = logging.getLogger(__name__)

class MediaController(BaseController):
	def getMedia139MailTypes(self) :
		response.headers['Content-Type'] = 'application/x-json'
		
		ret = list()
		if (not checkTimeScope('MediaController.getMedia139Types')) : return json.dumps(ret)
		from fidoweb.model.media import Media139MailType
		for t in Session.query(Media139MailType) : ret.append([t.id, t.name])
		return json.dumps(ret)
